package map.android.baidu.carpool.response;

import com.baidu.lbs.net.http.response.ComNetResponse;
import map.android.baidu.carpool.utils.LogUtils;

import java.io.Serializable;
import java.util.HashMap;

/**
 * Created by zhangtongyu on 15/3/23.
 * pay模块获取钱包支付参数的接口response
 */
public class GetPayResponse extends ComNetResponse implements Serializable{
    private static String TAG = "pay";
    private static final long serialVersionUID = -6255924348934122046L;

    public GetPayRoot data;

    public class GetPayRoot implements Serializable{

        private static final long serialVersionUID = 6365718301863630181L;

        public PayParam payParam;
        public String payUrl;
        public HongBaoInfo hongbao;

        public class PayParam implements Serializable {

            private static final long serialVersionUID = 8277690947772162208L;

            public String customerId;
            public String service;
            public String orderId;
            public String orderCreateTime;
            public String orderExpireTime;
            public String deviceType;
            public String payAmount;
            public String originalAmount;
            public String returnUrl;
            public String notifyUrl;
            public String defaultResPage;
            public String passuid;
            public String title;
            public String itemInfo;
            public String sdk;
            public String tpl;
            public String extData;
            public String signType;
            public String sign;
            public String mobile;

        }

        public class HongBaoInfo {
            public String hongbaoId;
            public String hongbaoType;
            public String hongbaoValue;
            public String hongbaoName;
        }
    }

    public String getYuanAmount(String fenAmount){

        int yuan = Integer.parseInt(fenAmount) / 100;

        return String.valueOf(yuan);
    }

    public String getFenAmount(String fenAmount){

        double yuan = Integer.parseInt(fenAmount) / 100;

        return String.valueOf(yuan);
    }

    @Override
    public boolean isBadResponse() {
        return false;
    }

    @Override
    public int getErrorNo() {
        return 0;
    }

    @Override
    public String getErrorMsg() {
        return null;
    }


    public HashMap<String, String> createDataHashMap(GetPayRoot data) {

        HashMap<String, String> dic = new HashMap<String, String>();
        LogUtils.d("TAG", "createDataHashMap() data = " + data);
        if (null != data) {
            dic.put("customerId", data.payParam.customerId);
            dic.put("defaultResPage", data.payParam.defaultResPage);
            dic.put("deviceType", data.payParam.deviceType);
            dic.put("extData", data.payParam.extData);
            dic.put("itemInfo", data.payParam.itemInfo);
            dic.put("mobile",data.payParam.mobile);
            dic.put("notifyUrl", data.payParam.notifyUrl);
            dic.put("orderCreateTime", data.payParam.orderCreateTime);
            dic.put("orderExpireTime", data.payParam.orderExpireTime);
            dic.put("orderId", data.payParam.orderId);
            dic.put("originalAmount", data.payParam.originalAmount);
            dic.put("passuid", data.payParam.passuid);
            dic.put("payAmount", data.payParam.payAmount);
            dic.put("returnUrl", data.payParam.returnUrl);
            dic.put("sdk", data.payParam.sdk);
            dic.put("service", data.payParam.service);
            dic.put("sign", data.payParam.sign);
            dic.put("signType", data.payParam.signType);
            dic.put("title", data.payParam.title);
        }

        LogUtils.d(TAG, "createDataHashMap() dic = " + dic);
        return dic;
    }
}
